package gokyesil.game2d.screens;

import gokyesil.game2d.Game2D;
import gokyesil.game2d.renderer.Assets;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Screen;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.scenes.scene2d.ui.Button;
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable;
import com.badlogic.gdx.utils.viewport.ScreenViewport;


public class MainScreen extends Stage implements Screen
{
	public Button newGame;
	public Button loadGame;
	public Button mapEditor;
	public Button settings;
	public Button quit;
	
	
	public MainScreen()
	{
		super();
	}
	

	@Override
	public void dispose() {
		// TODO Auto-generated method stub

	}

	@Override
	public void hide() {
		// TODO Auto-generated method stub
	}

	@Override
	public void pause() {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void render(float arg0) 
	{
		
		this.draw();	
	}

	@Override
	public void resize(int width, int height) 
	{
		ScreenViewport viewport = new ScreenViewport();
		viewport.update(width,height);
		this.setViewport(viewport);
		this.getCamera().position.set(Game2D.WIDTH/2,Game2D.HEIGHT/2,0);
		
	}

	@Override
	public void resume() {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void show() 
	{

		newGame = new Button( new TextureRegionDrawable(new TextureRegion(Assets.newGameImage)), new TextureRegionDrawable(new TextureRegion(Assets.newGameImage)));
		loadGame = new Button( new TextureRegionDrawable(new TextureRegion(Assets.loadGameImage)), new TextureRegionDrawable(new TextureRegion(Assets.loadGameImage)));
		mapEditor = new Button( new TextureRegionDrawable(new TextureRegion(Assets.mapEditorImage)), new TextureRegionDrawable(new TextureRegion(Assets.mapEditorImage)));
		settings = new Button( new TextureRegionDrawable(new TextureRegion(Assets.settingsImage)), new TextureRegionDrawable(new TextureRegion(Assets.settingsImage)));
		quit = new Button( new TextureRegionDrawable(new TextureRegion(Assets.quitImage)), new TextureRegionDrawable(new TextureRegion(Assets.quitImage)));
		
		newGame.setPosition(450, 500);
		loadGame.setPosition(450, 400);
		mapEditor.setPosition(450, 300);
		settings.setPosition(450, 200);
		quit.setPosition(450, 100);
		
		this.addActor(newGame);
		this.addActor(loadGame);
		this.addActor(mapEditor);
		this.addActor(settings);
		this.addActor(quit);
		
		Gdx.input.setInputProcessor(this);
		
		
		
	}

//	public boolean touchDown(int screenX, int screenY,int pointer, int button)
//	{
//		float ratioX = (float)originalWidth / (float)currentWidth;
//		float ratioY = (float)originalHeight / (float)currentHeight;
//		
//		
//		return super.touchDown((int)(screenX*ratioX), (int)(screenY*(1/ratioY)), pointer, button);
//		
//	}
//	
//	public boolean touchUp(int screenX, int screenY,int pointer, int button)
//	{
//		float ratioX = (float)originalWidth / (float)currentWidth;
//		float ratioY = (float)originalHeight / (float)currentHeight;
//		
//		
//		return super.touchUp((int)(screenX*ratioX), (int)(screenY*ratioY), pointer, button);
//		
//	}
	


}
